<template>
  <view class="box">
    <view class="left-box">
      <view class="card" v-for="(item, index) in cardlistLeft" :key="'box-left-' + index">
        <view class="card-top">
          <img class="card-img" :src="item.img" />
        </view>
        <view class="card-bottom">
          <view class="card-title">
            <view class="card-title-tag" v-if="item.realName">实名</view>
            <view class="card-title-content">{{ item.title }}</view>
          </view>
          <view class="card-des">{{ item.des }}</view>
          <view class="card-time" v-if="item.time">
            <view class="card-time-tag">专</view>
            <view class="card-time-content">{{ item.time }}</view>
          </view>
          <view class="card-price" v-if="item.price">
            <view class="card-price-unit">￥</view>
            <view class="card-price-num">{{ item.price }}</view>
            <view class="card-price-reward" v-if="item.reward">+打赏{{ item.reward }}</view>
          </view>
          <view class="card-detail">
            <view class="card-user">
              <view class="card-detail-img-box"><img class="card-detail-img" :src="eleven" /></view>
              <view class="card-user-name">{{ item.name }}</view>
            </view>
            <view class="card-detail-right">
              <view class="card-sure-box">
                <view class="card-detail-img-box">
                  <img class="card-detail-img" :src="item.isSure ? four : six" />
                </view>
                <view class="card-user-name">{{ item.sureNum }}</view>
              </view>
              <view class="card-love-box">
                <view class="card-detail-img-box">
                  <img class="card-detail-img" :src="item.isLove ? three : five" />
                </view>
                <view class="card-love-name">{{ item.loveNum }}</view>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
    <view class="right-box">
      <view class="card" v-for="(item, index) in cardlistRight" :key="'box-right-' + index">
        <view class="card-top">
          <img class="card-img" :src="item.img" />
        </view>
        <view class="card-bottom">
          <view class="card-title">
            <view class="card-title-tag" v-if="item.realName">实名</view>
            <view class="card-title-content">{{ item.title }}</view>
          </view>
          <view class="card-des">{{ item.des }}</view>
          <view class="card-time" v-if="item.time">
            <view class="card-time-tag">专</view>
            <view class="card-time-content">{{ item.time }}</view>
          </view>
          <view class="card-price" v-if="item.price">
            <view class="card-price-unit">￥</view>
            <view class="card-price-num">{{ item.price }}</view>
            <view class="card-price-reward" v-if="item.reward">+打赏{{ item.reward }}</view>
          </view>
          <view class="card-detail">
            <view class="card-user">
              <view class="card-detail-img-box"><img class="card-detail-img" :src="eleven" /></view>
              <view class="card-user-name">{{ item.name }}</view>
            </view>
            <view class="card-detail-right">
              <view class="card-sure-box">
                <view class="card-detail-img-box">
                  <img class="card-detail-img" :src="item.isSure ? four : six" />
                </view>
                <view class="card-user-name">{{ item.sureNum }}</view>
              </view>
              <view class="card-love-box">
                <view class="card-detail-img-box">
                  <img class="card-detail-img" :src="item.isLove ? three : five" />
                </view>
                <view class="card-love-name">{{ item.loveNum }}</view>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { reactive, ref } from 'vue'
import three from '@/static/images/3.png'
import four from '@/static/images/4.png'
import five from '@/static/images/5.png'
import six from '@/static/images/6.png'
import eleven from '@/static/images/11.jpg'
import twentyTwo from '@/static/images/22.jpg'

const cardlistLeft = ref([
  {
    img: eleven,
    title: '我是一个标题',
    des: '我是一个描述',
    time: '我是一个限定时间24年11月24日',
    name: '一个姓名',
    isLove: true,
    loveNum: 1344,
    isSure: true,
    sureNum: 1321,
    price: 0,
    realName: false,
    reward: 0,
  },
  {
    img: eleven,
    title: '我是一个标题',
    des: '我是一个描述',
    time: '',
    name: '一个姓名',
    isLove: false,
    loveNum: 134,
    isSure: false,
    sureNum: 121,
    price: 0,
    realName: false,
    reward: 0,
  },
  {
    img: twentyTwo,
    title: '我是一个标题',
    des: '我是一个描述',
    time: '',
    name: '一个姓名',
    isLove: false,
    loveNum: 1344,
    isSure: false,
    sureNum: 1321,
    price: 200,
    realName: true,
    reward: 100,
  },
])

const cardlistRight = ref([
  {
    img: twentyTwo,
    title: '我是一个标题',
    des: '我是一个描述',
    time: '',
    name: '一个姓名',
    isLove: false,
    loveNum: 134,
    isSure: false,
    sureNum: 121,
    price: 0,
    realName: false,
    reward: 0,
  },
  {
    img: twentyTwo,
    title: '我是一个标题',
    des: '我是一个描述',
    time: '',
    name: '一个姓名',
    isLove: false,
    loveNum: 1344,
    isSure: false,
    sureNum: 1321,
    price: 200,
    realName: true,
    reward: 0,
  },
])

// 测试 uni API 自动引入
onLoad(() => {})
</script>

<style scoped lang="scss">
.box {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.5rem;
  margin-right: -1rem;
  margin-left: -1rem;
  background: #f5f5f5ff;
  .left-box,
  .right-box {
    display: flex;
    flex-direction: column;
    width: calc(50% - 5rpx);
  }
}
.card {
  margin-bottom: 10rpx;
  background: #ffffffff;
  .card-top {
    position: relative;
    width: 100%;
    padding: 50% 0;
    overflow: hidden;
    border-radius: 10rpx;
    .card-img {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }
  }
  .card-bottom {
    padding: 10rpx;
    .card-title {
      display: flex;
      align-items: center;
      overflow: hidden;
      font-size: 23rpx;
      .card-title-tag {
        width: 43rpx;
        height: 25rpx;
        margin-right: 5rpx;
        font-size: 14rpx;
        line-height: 25rpx;
        color: #e73828ff;
        text-align: center;
        border: 1px solid #e73828ff;
        border-radius: 2.5rpx;
      }
      .card-title-content {
        flex: 1;
        font-weight: bold;
        color: #333333;
        text-overflow: ellipsis;
        word-wrap: nowrap;
        white-space: nowrap;
      }
    }
    .card-des {
      margin-top: 5rpx;
      overflow: hidden;
      font-size: 19rpx;
      color: #666666;
      text-overflow: ellipsis;
      word-wrap: nowrap;
      white-space: nowrap;
    }
    .card-time {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      margin-top: 5rpx;
      font-size: 19rpx;
      color: #f7b334;
      .card-time-tag {
        width: 30rpx;
        height: 30rpx;
        margin-right: 10rpx;
        line-height: 30rpx;
        text-align: center;
        background: #f7b3341a;
        border-radius: 2.5rpx;
      }
      .card-time-content {
        flex: 1;
        height: 30rpx;
        overflow: hidden;
        line-height: 30rpx;
        text-overflow: ellipsis;
        word-wrap: nowrap;
        white-space: nowrap;
        background: #f7b3341a;
        border-radius: 2.5rpx;
      }
    }
    .card-detail {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 15rpx;
      font-size: 19rpx;
      color: #999999ff;
      .card-detail-right {
        display: flex;
        align-items: center;
        justify-content: flex-end;
      }
      .card-user,
      .card-sure-box,
      .card-love-box {
        display: flex;
        align-items: center;
        .card-detail-img-box {
          display: block;
          width: 24rpx;
          height: 24rpx;
          margin-right: 5rpx;
          overflow: hidden;
          border-radius: 2.5rpx;
          .card-detail-img {
            width: 100%;
            height: 100%;
          }
        }
      }
      .card-user {
        color: #333333ff;
      }
      .card-sure-box,
      .card-love-box {
        margin-left: 8rpx;
      }
    }
    .card-price {
      display: flex;
      align-items: flex-end;
      justify-content: flex-end;
      font-weight: bold;
      color: #e73828ff;
      .card-price-unit {
        font-size: 19rpx;
      }
      .card-price-num {
        font-size: 30rpx;
      }
      .card-price-reward {
        font-size: 21rpx;
      }
    }
  }
}
</style>
